package cn.lili.controller.buyer.publish;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams;
import cn.lili.modules.promotion.entity.enums.CouponGetEnum;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.entity.vos.CouponVO;
import cn.lili.modules.publish.entity.LiPublishInformation;
import cn.lili.modules.publish.service.ILiPublishInformationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/buyer/publishInfo")
public class LiPublishInformationController {
    @Autowired
    private ILiPublishInformationService liPublishInformationService;

    /**
     * 查询信息发布列表
     */
    @ApiOperation(value="查询信息发布列表", notes="查询信息发布列表")
    @GetMapping("/list")
    public ResultMessage<IPage<LiPublishInformation>> list(LiPublishInformation liPublishInformation,
            @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
            @RequestParam(name="pageSize", defaultValue="10") Integer pageSize)
    {
        QueryWrapper<LiPublishInformation> queryWrapper = new QueryWrapper<>(liPublishInformation);
        Page<LiPublishInformation> page = new Page<>(pageNo,pageSize);
        Page<LiPublishInformation> pageList = liPublishInformationService.page(page, queryWrapper);
        return ResultUtil.data(pageList);
    }

    @ApiOperation("根据id查询")
    @GetMapping("/queryById")
    public ResultMessage<Page<LiPublishInformation>> queryById(LiPublishInformation liPublishInformation)
    {
        QueryWrapper<LiPublishInformation> queryWrapper = new QueryWrapper<>(liPublishInformation);
        Page<LiPublishInformation> page = new Page<>();
        Page<LiPublishInformation> pageList = liPublishInformationService.page(page, queryWrapper);
        return ResultUtil.data(pageList);
    }

    /**
     * 添加信息
     */
    @ApiOperation(value = "添加信息")
    @PostMapping("/add")
    public ResultMessage<String> add(@RequestBody LiPublishInformation liPublishInformation)
    {
        liPublishInformationService.save(liPublishInformation);
        return ResultUtil.data("添加成功");
    }

    /**
     * 修改信息
     */
    @ApiOperation(value = "修改信息")
    @PostMapping("/edit")
    public ResultMessage<String> edit(@RequestBody LiPublishInformation liPublishInformation)
    {
        liPublishInformationService.updateById(liPublishInformation);
        return ResultUtil.data("修改成功");
    }

    /**
     * 删除信息
     */
    @ApiOperation(value = "删除信息")
    @DeleteMapping("/delete")
    public ResultMessage<String> delete(@RequestParam(name = "id", required = true) String id)
    {
        liPublishInformationService.removeById(id);
        return ResultUtil.data("删除成功");
    }

//    /**
//     * 获取【请填写功能名称】详细信息
//     */
//    @GetMapping(value = "/{id}")
//    public ResultMessage getInfo(@PathVariable("id") Long id)
//    {
//        return success(liPublishInformationService.selectLiPublishInformationById(id));
//    }
//
//    /**
//     * 新增【请填写功能名称】
//     */
//
//    @PostMapping
//    public ResultMessage add(@RequestBody LiPublishInformation liPublishInformation)
//    {
//        return toAjax(liPublishInformationService.insertLiPublishInformation(liPublishInformation));
//    }
//
//    /**
//     * 修改【请填写功能名称】
//     */
//    @PutMapping
//    public ResultMessage edit(@RequestBody LiPublishInformation liPublishInformation)
//    {
//        return toAjax(liPublishInformationService.updateLiPublishInformation(liPublishInformation));
//    }
//
//    /**
//     * 删除【请填写功能名称】
//     */
//	@DeleteMapping("/{ids}")
//    public ResultMessage remove(@PathVariable Long[] ids)
//    {
//        return toAjax(liPublishInformationService.deleteLiPublishInformationByIds(ids));
//    }
}
